package com.huawei.ceiling;

import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;

public class StickyViewHolder {
    protected Component itemView;
    private Text nameTextView;

    public StickyViewHolder(Component parent) {
        this.itemView = parent;
        nameTextView = (Text) itemView.findComponentById(ResourceTable.Id_textview);
    }

    public void updateView(StickyBean stickyBean) {
        nameTextView.setText(stickyBean.getName());
        if (stickyBean.getType() == 1) {
            ShapeElement shapeElement = new ShapeElement();
            shapeElement.setRgbColor(new RgbColor(0, 0, 0));
            nameTextView.setBackground(shapeElement);
            nameTextView.setWidth(450);
            nameTextView.setHeight(150);
            nameTextView.setTextColor(Color.WHITE);
        } else {
            ShapeElement shapeElement = new ShapeElement();
            shapeElement.setRgbColor(new RgbColor(221, 255, 255));
            nameTextView.setBackground(shapeElement);
            ComponentContainer.LayoutConfig layoutConfig = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, 150);
            nameTextView.setLayoutConfig(layoutConfig);
            nameTextView.setTextColor(Color.GRAY);
        }
    }
}
